{% block sw_settings_showare_updates_index %}
<sw-page class="sw-settings-shopware-updates">

    {% block sw_settings_showare_updates_smart_bar_header %}
    <template #smart-bar-header>
        {% block sw_settings_showare_updates_smart_bar_header_title %}
        <h2>
            {% block sw_settings_showare_updates_smart_bar_header_title_text %}
            {{ $tc('sw-settings.index.title') }}
            <mt-icon
                name="regular-chevron-right-xs"
                size="12px"
            />
            {{ $tc('sw-settings-shopware-updates.general.emptyTitle') }}
            {% endblock %}
        </h2>
        {% endblock %}
    </template>
    {% endblock %}

    {% block sw_settings_showare_updates_smart_bar_actions %}
    <template #smart-bar-actions>
        {% block sw_settings_showare_updates_actions_save %}
        <sw-button-process
            class="sw-store-detail__save-action"
            :is-loading="isLoading"
            :process-success="isSaveSuccessful"
            :disabled="isLoading"
            variant="primary"
            @update:process-success="saveFinish"
            @click="onSave()"
        >
            {{ $tc('sw-settings-store.general.buttonSave') }}
        </sw-button-process>
        {% endblock %}
    </template>
    {% endblock %}

    {% block sw_settings_showare_updates_content %}
    <template #content>
        <sw-card-view>
            <sw-skeleton v-if="isLoading" />

            {# v-show is used here as underlying components influence the loading state and v-if would destroy this behaviour #}
            <sw-system-config
                v-show="!isLoading"
                ref="systemConfig"
                domain="core.update"
                @loading-changed="onLoadingChanged"
            >
                <template #card-element-last>
                    <div class="sw-settings-shopware-updates-index__check-for-updates-btn">
                        <mt-button
                            ghost
                            :is-loading="isSearchingForUpdates"
                            variant="secondary"
                            @click="searchForUpdates"
                        >
                            {{ $t('sw-settings-shopware-updates.general.checkForUpdates') }}
                        </mt-button>
                        <span class="sw-settings-shopware-updates-index__current-version">
                            {{ $t('sw-settings-shopware-updates.general.currentVersion') }} {{ shopwareVersion }}
                        </span>
                    </div>
                </template>
            </sw-system-config>
        </sw-card-view>

        <sw-modal
            v-if="updateModalShown"
            :title="$t('sw-settings-shopware-updates.general.emptyTitle')"
            variant="small"
            @modal-close="updateModalShown = false"
        >
            {{ $t('sw-settings-shopware-updates.updateModal.messageUpdateCheck', {version: updateInfo.version}) }}

            <template #modal-footer>
                <mt-button
                    size="small"
                    variant="secondary"
                    @click="updateModalShown = false"
                >
                    {{ $tc('global.default.cancel') }}
                </mt-button>

                <mt-button
                    variant="primary"
                    size="small"
                    @click="openUpdateWizard()"
                >
                    {{ $tc('sw-settings-shopware-updates.updateModal.actions.goToUpdate') }}
                </mt-button>
            </template>
        </sw-modal>
    </template>
    {% endblock %}
</sw-page>
{% endblock %}
